﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>预装载图片提高站点速度</title>
    <script type="text/javascript" language="JavaScript">
        // 用数组存储需要的图片
        var imgList = [];
        imgList[0] = "logo1.gif";
        imgList[1] = "logo2.gif";
        // 用户单机按钮时，提取图像的方法
        function getImage(index){
            let imgsrc = imgList[index];
            document.getElementById("img1").src = imgsrc;
        }

    </script>
</head>
<body>
<table id="mytbl" width="300" height="50" border="0" cellspacing="2" cellpadding="0" bgcolor="#FFb609">
    <tr>
        <td> 显示第一张图片<input id="btn1" type="button" value="显示" onclick="getImage(0)" /></td><td><img id="img1" src=""></td>
    </tr>
    <tr>
        <td> 显示第二章图片<input id="btn2" type="button" value="显示" onclick="getImage(1)" /></td><td>预先装载图片</td>
    </tr>
</table>
</body>
</html>